Skip to main content

Class SimulatedSamplingSensorBase<UNIT>

Represents the base logic for a simulated sample sensor

Assembly: Meadow.Foundation.dll​
View Source​
Declaration
public abstract class SimulatedSamplingSensorBase<UNIT> : SimulatedSensorBase, ISimulatedSensor, ISamplingSensor<UNIT>, ISensor<UNIT>, ISensor, ISamplingSensor where UNIT : struct

Inheritance: System.Object -> Meadow.Foundation.Sensors.SimulatedSensorBase

Derived:
Meadow.Foundation.Sensors.SimulatedAccelerometer

Implements:
Meadow.Peripherals.Sensors.ISimulatedSensor, Meadow.Peripherals.Sensors.ISamplingSensor<<UNIT>>, Meadow.Peripherals.Sensors.ISensor<<UNIT>>, Meadow.Peripherals.Sensors.ISensor, Meadow.Peripherals.Sensors.ISamplingSensor

Properties​

UpdateInterval​

A TimeSpan that specifies how long to wait between readings

View Source​
Declaration
public TimeSpan UpdateInterval { get; }

IsSampling​

Gets a value indicating whether the sensor is currently sampling

View Source​
Declaration
public bool IsSampling { get; }

PreviousReading​

View Source​
Declaration
protected UNIT? PreviousReading { get; }

Methods​

GenerateSimulatedValue(SimulationBehavior)​

Generates a value based on the provided behavior

View Source​
Declaration
protected abstract UNIT GenerateSimulatedValue(SimulationBehavior behavior)
Returns​

<UNIT>

Parameters​
TypeNameDescription
Meadow.Peripherals.Sensors.SimulationBehaviorbehaviorThe behavior to use when generating a value

Read()​

Convenience method to get the current sensor reading

View Source​
Declaration
public Task<UNIT> Read()
Returns​

System.Threading.Tasks.Task<<UNIT>>

StartUpdating(TimeSpan?)​

Starts updating the sensor on the updateInterval frequency specified

View Source​
Declaration
public void StartUpdating(TimeSpan? updateInterval = null)
Parameters​
TypeNameDescription
System.Nullable<System.TimeSpan>updateIntervalA TimeSpan that specifies how long to
wait between readings

StopUpdating()​

Stops sampling the sensor

View Source​
Declaration
public void StopUpdating()

Events​

Updated​

Raised when a change is detected

View Source​
Declaration
public event EventHandler<IChangeResult<UNIT>>? Updated
Event Type​

System.EventHandler<Meadow.IChangeResult<<UNIT>>>

Implements​

  • Meadow.Peripherals.Sensors.ISimulatedSensor
  • Meadow.Peripherals.Sensors.ISamplingSensor<<UNIT>>
  • Meadow.Peripherals.Sensors.ISensor<<UNIT>>
  • Meadow.Peripherals.Sensors.ISensor
  • Meadow.Peripherals.Sensors.ISamplingSensor